hysop.backend.device.opencl.opencl_operator module

Abstract class providing a common interface to all discrete operators working on the OpenCl backend.

  • OpenClOperator is an abstract class

    used to provide a common interface to all discrete operators working on the opencl backend.

class hysop.backend.device.opencl.opencl_operator.OpenClOperator(cl_env=None, mpi_params=None, requested_symbolic_kernels=None, **kwds)[source]

Bases: ComputationalGraphOperator

Abstract class for discrete operators working on OpenCL backends.

Create the common attributes of all OpenCL operators. See handle_method() and setup().

All input and output variable topologies should be of kind Backend.OPENCL and share the same OpenClEnvironment.

cl_env

OpenCL environment shared accross all topologies.

Type:

OpenClEnvironment

Notes

About method keys:
OpenClKernelConfig: user build options, defines, precision

and autotuner configuration

classmethod available_methods()[source]

Returns the available methods of this node. This should return a dictionary of method as keys and possible values as a scalar or an iterable. See hysop.types.InstanceOf to support specific class types. This is used to check user method input.

build_options()[source]

Build and return opencl build option string from self._cl_build_options and self._cl_defines.

check()[source]

Check if node was correctly initialized. This calls ComputationalGraphNode.check() and then checks backend by comparing all variables topology backend to set.supported_backends().

check_dfield_memory_order(df)[source]
check_memory_order()[source]
create_topology_descriptors()[source]
Called in get_field_requirements, just after handle_method
Topology requirements (or descriptors) are:
  1. min and max ghosts for each input and output variables

  2. allowed splitting directions for cartesian topologies

classmethod default_method()[source]

Returns the default method of this node. Default methods should be compatible with available_methods. If the user provided method dictionnaty misses some method keys, a default value for this key will be extracted from the default one.

discretize()[source]

By default, an operator discretize all its variables. For each input continuous field that is also an output field, input topology may be different from the output topology.

After this call, one can access self.input_discrete_fields and self.output_discrete_fields, which contains input and output dicretised fields mapped by continuous fields.

self.discrete_fields will be a tuple containing all input and output discrete fields.

Discrete tensor fields are built back from discretized scalar fields and are accessible from self.input_tensor_fields, self.output_tensor_fields and self.discrete_tensor_fields like their scalar counterpart.

get_field_requirements()[source]

Called just after handle_method(), ie self.method has been set. topology requirements are:

  1. min and max ghosts for each input and output variables

  2. allowed splitting directions for cartesian topologies

3) required local and global transposition state, if any. and more

they are stored in self.input_field_requirements and self.output_field_requirements.

keys are continuous fields and values are of type hysop.fields.field_requirement.discretefieldrequirements

default is backend.opencl, no min or max ghosts and no specific transposition state for each input and output variables.

handle_method(method)[source]

Extract device configuration and precision from OpenClKernelConfig.

setup(work)[source]

Setup temporary buffer that have been requested in get_work_properties(). This function may be used to execute post allocation routines. This sets self.ready flag to True. Once this flag is set one may call ComputationalGraphNode.apply() and ComputationalGraphNode.finalize().

Automatically honour temporary field memory requests.

classmethod supported_backends()[source]

Return the backends that this operator’s topologies can support.

classmethod supports_multiple_topologies()[source]

Should return True if this node supports multiple topologies.